package com.leador.http;

import android.content.Context;
import android.util.Log;

import com.leador.listener.BaseTraceListener;
import com.leador.listener.OnTrackListener;
import com.leador.module.response.Result;
import com.leador.module.response.track.TrackResult;
import com.leador.utils.HttpTraceClientExchangeUtil;

import java.io.File;
import java.util.Map;

/**
 * Created by liuha on 2016/9/18.
 */
public class Request {
    public static  void request(Context context, HttpTraceClientExchangeUtil httpTraceClientExchangeUtil){
        if(httpTraceClientExchangeUtil == null){
            return;
        }
        HttpCore httpCore = new HttpCore(context);
        httpCore.setEncty(httpTraceClientExchangeUtil.getEncrypt());
        httpCore.setArg(httpTraceClientExchangeUtil.getArg());
        httpCore.setBackFlag(httpTraceClientExchangeUtil.getBackFlag());
        httpCore.setRequstType(httpTraceClientExchangeUtil.getRequstType());
        httpCore.setDiscern(httpTraceClientExchangeUtil.getDiscern());
        httpCore.setBaseUrl(httpTraceClientExchangeUtil.getUrl());
        httpCore.start();
    }

    public static  void setRequest(Context context, HttpTraceClientExchangeUtil httpTraceClientExchangeUtil){
        HttpCore httpCore = new HttpCore(context);
        httpCore.setEncty(httpTraceClientExchangeUtil.getEncrypt());
        httpCore.setArg(httpTraceClientExchangeUtil.getArg());
        httpCore.setBackFlag(httpTraceClientExchangeUtil.getBackFlag());
        httpCore.setRequstType(httpTraceClientExchangeUtil.getRequstType());
        httpCore.setDiscern(httpTraceClientExchangeUtil.getDiscern());
        httpCore.setBaseUrl(httpTraceClientExchangeUtil.getUrl());
        httpCore.start();
    }

    public static void setFileRequest(Context context, File file, Map<String,String> map, HttpTraceClientExchangeUtil httpTraceClientExchangeUtil){
        HttpCore httpCore = new HttpCore(context);
        httpCore.setPitch(true);
        httpCore.setFile(file);
        httpCore.setParams(map);
        httpCore.setEncty(httpTraceClientExchangeUtil.getEncrypt());
        httpCore.setArg(httpTraceClientExchangeUtil.getArg());
        httpCore.setBackFlag(httpTraceClientExchangeUtil.getBackFlag());
        httpCore.setRequstType(httpTraceClientExchangeUtil.getRequstType());
        httpCore.setDiscern(httpTraceClientExchangeUtil.getDiscern());
        httpCore.setBaseUrl(httpTraceClientExchangeUtil.getUrl());
        httpCore.start();
    }
}
